﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Repository.Models
{
    public class ChildAttendance : BusinessFullEntityBase<Guid>
    {
        /// <summary>
        /// 幼儿id
        /// </summary>
        public Guid ChildId { get; set; }

        /// <summary>
        /// 幼儿信息
        /// </summary>
        public Childrens? Children { get; set; }

        /// <summary>
        /// 幼儿规则id
        /// </summary>
        public Guid ChildAttendanceRuleId { get; set; }

        /// <summary>
        /// 幼儿规则
        /// </summary>
        public ChildAttendanceRule? ChildAttendanceRule { get; set; }

        /// <summary>
        /// 考勤原始记录id集合（","隔开）
        /// </summary>
        public string? AttendanceRecordIds { get; set; }

        /// <summary>
        /// 今天日期
        /// </summary>
        public DateTime? Today { get; set; }

        /// <summary>
        /// 考勤入园时间
        /// </summary>
        public DateTime? AttendanceEntryTime { get; set; }

        /// <summary>
        /// 考勤出园时间
        /// </summary>
        public DateTime? OutSchoolTime { get; set; }

        /// <summary>
        /// 是否迟到
        /// </summary>
        public bool? IsLate { get; set; } = false;

        /// <summary>
        /// 是否早退
        /// </summary>
        public bool? IsEarly { get; set; } = false;


        public override void ConfigureEntity(ModelBuilder builder)
        {
            // 复合主键设置
            builder.Entity<ChildAttendance>()
                .HasKey(e => new { e.ChildId, e.ChildAttendanceRuleId });

            // 索引设置
            builder.Entity<ChildAttendance>()
                .HasIndex(e => new { e.ChildId, e.ChildAttendanceRuleId })
                .IsUnique(false);
        }
    }
}
